

*combine data

	clear
	gen state=""
	tempfile tmp
	save `tmp'
		* 
	 foreach state in AR AZ CA CO LA FL MI NV OK ME MT MO OH SD { 	
		local files : dir "../data_output/" files "total_floorvotes_`state'*.dta"
		foreach file in `files' {
project, uses(../data_output/`file')		
			use ../data_output/`file', clear
			append using `tmp'
			save `tmp', replace
		}
	}
	replace state= upper(state)
	bys state chamber term: egen max = max(floorvotes)
	gen pct_floorvotes = 100*floorvotes/max
	bys state chamber term: egen max_close = max(close_floorvotes)
	gen pct_close_floorvotes = 100*close_floorvotes/max_close	
	keep state  vote_against_party vote_party_line *floorvotes CandId term
	save ../data_output/floorvotes.dta, replace
project, creates(../data_output/floorvotes.dta)	
	
	
	
	*prep committee voting data
	clear
	gen state=""
	tempfile tmp
	save `tmp'
		* 
	qui foreach state in  AZ CA CO FL SD {   
		local files : dir "../data_output/" files "total_cmtvotes_`state'*.dta"
		foreach file in `files' {
project, uses(../data_output/`file'	)	
			use ../data_output/`file', clear
			append using `tmp'
			save `tmp', replace
		}
	}
	replace state= upper(state)
	bys state chamber term: egen max = max(cmtvotes)
	gen pct_cmtvotes = 100*cmtvotes/max
	rename vote_against_party cmtvote_against_party
	rename vote_party_line cmtvote_party_line
	keep state  cmtvote_against_party cmtvote_party_line *cmtvotes CandId term
	save ../data_output/cmtvotes.dta, replace	
project, creates(../data_output/cmtvotes.dta)	
	

	*prep content sponsor data
	clear
	gen state=""
	tempfile tmp
	save `tmp'
		
	 foreach state in AR  CA MI NV  OK AZ  CO FL LA ME MI MO MT OH SD  { // 
		local files : dir "../data_output/" files "bills_by_sponsor_`state'*.dta"
		foreach file in `files' {
project, uses(../data_output/`file')
			use ../data_output/`file', clear
			keep bill subject CandId term state chamber	
			append using `tmp'
			save `tmp', replace
		}
	}
	save ../data_output/tmp_allbills, replace
project, creates(../data_output/tmp_allbills.dta)	
	
